package cn.com.mdx.sort.heapsort.eventdrivensimulation;

import edu.princeton.cs.algs4.StdDraw;

import java.util.Random;

/**
 * <p> 弹跳球
 *
 * @author ：huangy
 * @date ：Created in 2020/10/19 5:19 下午
 */
public class BouncingBalls {

    public static void main(String[] args) {
        int N = 40;
        Random random = new Random();
        Ball[] balls = new Ball[N];
        for (int i = 0; i < N; i++)
            //初始位置和初始速度
            balls[i] = new Ball(random.nextInt(10) * 0.01, random.nextInt(10) * 0.01,
                    random.nextInt(10) * 0.01, random.nextInt(10) * 0.01);
        while (true) {
            StdDraw.clear();
            for (int i = 0; i < N; i++) {
                balls[i].move(0.5);
                balls[i].draw();
            }
            StdDraw.show(50);
        }
    }

}
